package io.github.wppli.domain.posts.model.http;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author li--jiaqiang 2025−03−11
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PublishPostsRequest {

    /**
     * 照片数组
     */
    private List<String> images;

    /**
     * 帖子标题
     */
    private String title;

    /**
     * 正文
     */
    private String content;

    /**
     * '可见范围（0-私有 1-公开）'
     */
    private Integer isPublic = 1;

    // 生成上述字段的判空校验
    public void validate() {
        if (images == null || images.isEmpty()) {
            throw new IllegalArgumentException("images is required");
        }
        if (title == null || title.isEmpty()) {
            throw new IllegalArgumentException("title is required");
        }
        if (content == null || content.isEmpty()) {
            throw new IllegalArgumentException("content is required");
        }
        if (isPublic == null) {
            throw new IllegalArgumentException("isPublic is required");
        }
    }

}